class MapAPI {
  // 获取设备信息（包含经纬度坐标信息）

  static getDeviceList() {
    return new Promise((resolve) => {
      setTimeout(() => {
        const mockData = {
          data: {
            pageSize: 10,
            total: 9,
            pageNum: 1,
            startRowNum: 0,
            condition: {
              startRowNum: 0,
              pageSize: 10,
            },
            list: [
              {
                gid: "1793184301483819008",
                createTime: "2024-05-22 07:37:08",
                createBy: 0,
                updateTime: null,
                updateBy: null,
                modelSet: "222",
                compressorMode: "1771804513501376515",
                stationInfo: "1789107433512108032",
                batchInfo: "1771477547720093698",
                orderNo: null,
                sn: "11",
                unumber: "111",
                deliveryTime: "2024-05-08 12:00:00",
                proTime: null,
                intakePressure: "111",
                outtakePressure: "111",
                designPressure: "111",
                airDis: "11",
                status: 0,
                mark: null,
                other: null,
                baud: 11,
                dbits: null,
                sbits: null,
                dadr: "111",
                parityTest: null,
                coordinate: "114.09208981872558,30.627662955741886",
                address:
                  "湖北省武汉市东西湖区径河街道东吴大道20号春辉工业园西北约86米",
                clazz: null,
                compressorModeName: "RDSC554-2/YBBP710-6",
                stationInfoName: "文23先导",
                batchName: "一期1",
              },
              {
                gid: "1793183838386520064",
                createTime: "2024-05-22 07:35:17",
                createBy: 0,
                updateTime: null,
                updateBy: null,
                modelSet: "111",
                compressorMode: "1771804513501376515",
                stationInfo: "1783070059622510594",
                batchInfo: "1771477547720093698",
                orderNo: null,
                sn: "111",
                unumber: "111",
                deliveryTime: "2024-05-02 12:00:00",
                proTime: null,
                intakePressure: "111",
                outtakePressure: "111",
                designPressure: "111",
                airDis: "111",
                status: 0,
                mark: null,
                other: null,
                baud: 1,
                dbits: null,
                sbits: null,
                dadr: "111",
                parityTest: null,
                coordinate: "114.08522336364746,30.657188712577824",
                address: "湖北省武汉市东西湖区走马岭街道1渔线东北约542米",
                clazz: null,
                compressorModeName: "RDSC554-2/YBBP710-6",
                stationInfoName: "10号站",
                batchName: "一期1",
              },
              {
                gid: "1793183623143227392",
                createTime: "2024-05-22 07:34:26",
                createBy: 0,
                updateTime: null,
                updateBy: null,
                modelSet: "111",
                compressorMode: "1771804513501376515",
                stationInfo: "1771468544608751618",
                batchInfo: "1771477547720093698",
                orderNo: null,
                sn: "111",
                unumber: "111",
                deliveryTime: "2024-05-09 12:00:00",
                proTime: null,
                intakePressure: "111",
                outtakePressure: "111",
                designPressure: "11",
                airDis: "111",
                status: 0,
                mark: null,
                other: null,
                baud: 2,
                dbits: null,
                sbits: null,
                dadr: "111",
                parityTest: null,
                coordinate: "114.25413815856933,30.608093558769227",
                address:
                  "湖北省武汉市江汉区常青街道青年路488附3西北方向140米西北约100米",
                clazz: null,
                compressorModeName: "RDSC554-2/YBBP710-6",
                stationInfoName: "江汉油田分公司",
                batchName: "一期1",
              },
              {
                gid: "1783079794325270530",
                createTime: "2024-04-24 10:25:25",
                createBy: null,
                updateTime: null,
                updateBy: null,
                modelSet: "往复式压缩机",
                compressorMode: "1771804513501376515",
                stationInfo: "1783070059622510594",
                batchInfo: "1783079794132332545",
                orderNo: null,
                sn: "R20200308",
                unumber: null,
                deliveryTime: "2020-08-31 16:00:00",
                proTime: null,
                intakePressure: "0.2~0.6",
                outtakePressure: "2.6",
                designPressure: null,
                airDis: "12.6~61.7",
                status: 1,
                mark: null,
                other: null,
                baud: 9600,
                dbits: 8,
                sbits: 1,
                dadr: "11、12、13...",
                parityTest: 0,
                coordinate: null,
                address: null,
                clazz: null,
                compressorModeName: "RDSC554-2/YBBP710-6",
                stationInfoName: "10号站",
                batchName: "增压1701C",
              },
              {
                gid: "1783079742257180674",
                createTime: "2024-04-24 10:25:13",
                createBy: null,
                updateTime: null,
                updateBy: null,
                modelSet: "往复式压缩机",
                compressorMode: "1771804513501376515",
                stationInfo: "1783070059622510594",
                batchInfo: "1783079742064242690",
                orderNo: null,
                sn: "R20200307",
                unumber: null,
                deliveryTime: "2020-08-31 16:00:00",
                proTime: null,
                intakePressure: "0.2~0.6",
                outtakePressure: "2.6",
                designPressure: null,
                airDis: "12.6~61.7",
                status: 1,
                mark: null,
                other: null,
                baud: 9600,
                dbits: 8,
                sbits: 1,
                dadr: "11、12、13...",
                parityTest: 0,
                coordinate: null,
                address: null,
                clazz: null,
                compressorModeName: "RDSC554-2/YBBP710-6",
                stationInfoName: "10号站",
                batchName: "增压1701D",
              },
              {
                gid: "1783079517966774274",
                createTime: "2024-04-24 10:24:19",
                createBy: null,
                updateTime: null,
                updateBy: null,
                modelSet: "往复式压缩机",
                compressorMode: "1771804513501376515",
                stationInfo: "1783070059622510594",
                batchInfo: "1783079517840945154",
                orderNo: null,
                sn: "R20200306",
                unumber: null,
                deliveryTime: "2020-08-31 16:00:00",
                proTime: null,
                intakePressure: "0.2~0.6",
                outtakePressure: "2.6",
                designPressure: null,
                airDis: "12.6~61.7",
                status: 1,
                mark: null,
                other: null,
                baud: 9600,
                dbits: 8,
                sbits: 1,
                dadr: "11、12、13...",
                parityTest: 0,
                coordinate: null,
                address: null,
                clazz: null,
                compressorModeName: "RDSC554-2/YBBP710-6",
                stationInfoName: "10号站",
                batchName: "增压1701B",
              },
              {
                gid: "1783079081692049410",
                createTime: "2024-04-24 10:22:35",
                createBy: null,
                updateTime: null,
                updateBy: null,
                modelSet: "往复式压缩机",
                compressorMode: "1771804513501376515",
                stationInfo: "1783070059622510594",
                batchInfo: "1783079014222475265",
                orderNo: null,
                sn: "R20200305",
                unumber: null,
                deliveryTime: "2020-08-31 16:00:00",
                proTime: null,
                intakePressure: "0.2~0.6",
                outtakePressure: "2.6",
                designPressure: null,
                airDis: "12.6~61.7",
                status: 1,
                mark: null,
                other: null,
                baud: 9600,
                dbits: 8,
                sbits: 1,
                dadr: "11、12、13...",
                parityTest: 0,
                coordinate: null,
                address: null,
                clazz: null,
                compressorModeName: "RDSC554-2/YBBP710-6",
                stationInfoName: "10号站",
                batchName: "增压1701A",
              },
              {
                gid: "1780868671372001280",
                createTime: "2024-04-18 07:59:13",
                createBy: 0,
                updateTime: null,
                updateBy: null,
                modelSet: "往复式压缩机二号",
                compressorMode: "1771804513501376515",
                stationInfo: "1786377611610423296",
                batchInfo: "1771477547720093698",
                orderNo: 57,
                sn: "CB202206050002",
                unumber: "CC01",
                deliveryTime: "2024-04-10 12:00:00",
                proTime: "2018-12-01 16:00:00",
                intakePressure: "200",
                outtakePressure: "30-900",
                designPressure: "25-2000",
                airDis: "9000",
                status: 1,
                mark: null,
                other: null,
                baud: 9600,
                dbits: 8,
                sbits: 1,
                dadr: "湖北省武汉市",
                parityTest: 0,
                coordinate: "114.26915852905275,30.64053004673265",
                address:
                  "湖北省武汉市江岸区塔子湖街道后湖大道与塔子湖西路交叉附近东北约86米",
                clazz: null,
                compressorModeName: "RDSC554-2/YBBP710-6",
                stationInfoName: "海洋一号",
                batchName: "一期1",
              },
              {
                gid: "1771746225631981569",
                createTime: "2024-01-01 00:00:00",
                createBy: null,
                updateTime: null,
                updateBy: null,
                modelSet: "往复式压缩机一号",
                compressorMode: "1771804513501376515",
                stationInfo: "1786377611610423296",
                batchInfo: "1771477547720093698",
                orderNo: 57,
                sn: "C20180232",
                unumber: "1号机组",
                deliveryTime: "2018-10-31 16:00:00",
                proTime: "2018-12-01 16:00:00",
                intakePressure: "1.0-3.0",
                outtakePressure: "5.5-6.0",
                designPressure: "200",
                airDis: "2.43～8.03×10^4",
                status: 1,
                mark: null,
                other: null,
                baud: 9600,
                dbits: 8,
                sbits: 1,
                dadr: "湖北省武汉市",
                parityTest: 0,
                coordinate: "114.27199655593995,30.50928204735325",
                address:
                  "湖北省武汉市武昌区白沙洲街道长江路28附12正北方向90米观澜天地西门西北约154米",
                clazz: null,
                compressorModeName: "RDSC554-2/YBBP710-6",
                stationInfoName: "海洋一号",
                batchName: "一期1",
              },
            ],
            totalPageNum: 1,
          },
          resMsg: "操作成功",
          resCode: "00000",
        };
        resolve(mockData);
      }, 300);
    });
  }
  // 根据提供的参数从天地图 API 获取地理编码信息，并返回 JSON 格式的响应数据。
  static getAddress(params: any) {
    let url = "http://api.tianditu.gov.cn/geocoder";
    if (params) {
      const paramsArray: any = [];
      // 拼接参数
      Object.keys(params).forEach((key) => {
        if (key === "postStr") {
          paramsArray.push(key + "=" + JSON.stringify(params[key]));
        } else {
          paramsArray.push(key + "=" + params[key]);
        }
      });
      if (url.search(/\?/) === -1) {
        url += "?" + paramsArray.join("&");
      } else {
        url += "&" + paramsArray.join("&");
      }
    }
    return fetch(url).then((response) => response.json());
  }
  // 查询所有地图设置,天地图（Tianditu）的影像服务配置,以便在地图应用中加载天地图提供的影像图层。
  static findAllTileInfoInList(params: any) {
    return new Promise((resolve) => {
      setTimeout(() => {
        const mockData = {
          data: [
            {
              gid: "1633756299973885952",
              createTime: "2023-03-09 09:07:10",
              createBy: 0,
              updateTime: null,
              updateBy: null,
              tileName: "天地图影像服务",
              tileService:
                "http://t4.tianditu.gov.cn/vec_c/wmts?tk=5ec3e996393521a1a9fb1681f13201ff",
              tileType: "WMTS",
              options:
                '{"layers":"vec","matrixSet":"c","format":"tiles","projection":"EPSG:4326","style":"default"}',
              tileStatus: "显示",
            },
            {
              gid: "1633756509290627072",
              createTime: "2023-03-09 09:08:00",
              createBy: 0,
              updateTime: null,
              updateBy: null,
              tileName: "天地图注记服务",
              tileService:
                "http://t0.tianditu.gov.cn/cva_c/wmts?tk=5ec3e996393521a1a9fb1681f13201ff",
              tileType: "WMTS",
              options:
                '{"layers":"cva","matrixSet":"c","format":"tiles","projection":"EPSG:4326","style":"default"}',
              tileStatus: "显示",
            },
          ],
          resMsg: "操作成功",
          resCode: "00000",
        };
        resolve(mockData);
      }, 300);
    });
  }

  static getCompressorInfoAll(params: any) {
    return new Promise((resolve) => {
        setTimeout(() => {
          const mockData = {
            data: [
                {
                    "gid": "1771746225631981569",
                    "createTime": "2024-01-01 00:00:00",
                    "createBy": null,
                    "updateTime": null,
                    "updateBy": null,
                    "modelSet": "往复式压缩机一号",
                    "compressorMode": "1771804513501376515",
                    "stationInfo": "1786377611610423296",
                    "batchInfo": "1771477547720093698",
                    "orderNo": 57,
                    "sn": "C20180232",
                    "unumber": "1号机组",
                    "deliveryTime": "2018-10-31 16:00:00",
                    "proTime": "2018-12-01 16:00:00",
                    "intakePressure": "1.0-3.0",
                    "outtakePressure": "5.5-6.0",
                    "designPressure": "200",
                    "airDis": "2.43～8.03×10^4",
                    "status": 1,
                    "mark": null,
                    "other": null,
                    "baud": 9600,
                    "dbits": 8,
                    "sbits": 1,
                    "dadr": "湖北省武汉市",
                    "parityTest": 0,
                    "coordinate": "114.27199655593995,30.50928204735325",
                    "address": "湖北省武汉市武昌区白沙洲街道长江路28附12正北方向90米观澜天地西门西北约154米"
                },
                {
                    "gid": "1780868671372001280",
                    "createTime": "2024-04-18 07:59:13",
                    "createBy": 0,
                    "updateTime": null,
                    "updateBy": null,
                    "modelSet": "往复式压缩机二号",
                    "compressorMode": "1771804513501376515",
                    "stationInfo": "1786377611610423296",
                    "batchInfo": "1771477547720093698",
                    "orderNo": 57,
                    "sn": "CB202206050002",
                    "unumber": "CC01",
                    "deliveryTime": "2024-04-10 12:00:00",
                    "proTime": "2018-12-01 16:00:00",
                    "intakePressure": "200",
                    "outtakePressure": "30-900",
                    "designPressure": "25-2000",
                    "airDis": "9000",
                    "status": 1,
                    "mark": null,
                    "other": null,
                    "baud": 9600,
                    "dbits": 8,
                    "sbits": 1,
                    "dadr": "湖北省武汉市",
                    "parityTest": 0,
                    "coordinate": "114.26915852905275,30.64053004673265",
                    "address": "湖北省武汉市江岸区塔子湖街道后湖大道与塔子湖西路交叉附近东北约86米"
                },
                {
                    "gid": "1783064104641892353",
                    "createTime": "2024-04-24 09:23:04",
                    "createBy": null,
                    "updateTime": null,
                    "updateBy": null,
                    "modelSet": "往复式压缩机",
                    "compressorMode": "1783058135409127425",
                    "stationInfo": "1786381442020802560",
                    "batchInfo": "1783058135996329986",
                    "orderNo": 2,
                    "sn": "C20180220",
                    "unumber": "1号机组",
                    "deliveryTime": "2018-08-28 16:00:00",
                    "proTime": "2018-09-25 16:00:00",
                    "intakePressure": "1.0-3.0",
                    "outtakePressure": "5.5-6.0",
                    "designPressure": "3",
                    "airDis": "3.67～12.12×10^4",
                    "status": 1,
                    "mark": null,
                    "other": null,
                    "baud": 9600,
                    "dbits": 8,
                    "sbits": 1,
                    "dadr": "11、12、13...",
                    "parityTest": 0,
                    "coordinate": null,
                    "address": null
                },
            ],
            resMsg: "操作成功",
            resCode: "00000",
          };
          resolve(mockData);
        }, 300);
      });
  }
}

export default MapAPI;
